#include <gtk/gtk.h>
#include <stdio.h>

#include "gtkutils.h"

void sayHello() {
    printf("hello word\n");
}

static void activate(GtkApplication *app, gpointer user_data) {
    GtkWindow *window;

    window = createWindowWithTitleSize(app, "gtk-desktop-generator", -1, -1);

    GtkBox *mainBox = createBoxWithVerticalAppends(5, 
        createFrameWithChild("Desktop Entry", createBoxWithVerticalAppends(5, 
            createBoxWithHorizntalAppends(5,
                createLabel("文件路径存放:"),
                createComboBoxExpand(),
                createButton("选择路径"),
                NULL
            ),
            createBoxWithHorizntalAppends(5,
                createLabel("文件版本:"),
                createEntryExpand(),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("显示的名称:"),
                createEntryExpand(),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("文件说明:"),
                createEntryExpand(),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("文件类型:"),
                createComboBoxExpand(),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("执行文件选择:"),
                createEntryExpand(),
                createButton("参数设定"),
                createButton("选择文件"),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("图标文件选择:"),
                createEntryExpand(),
                createImage(),
                createButton("选择图标"),
                NULL
            ),
            createBoxWithHorizntalAppends(5, 
                createLabel("程序分类:"),
                createComboBoxExpand(),
                NULL
            ),
            NULL
        )),
        createFrameWithChild("Show Coment", createBoxWithVerticalAppends(5, 
                createTextView(),
                createBoxWithHorizntalAppends(5, 
                    createButton("复制到剪贴板"),
                    createButton("保存到文件"),
                    NULL
                ),
                NULL
            )),
        NULL
    );
    setWidgetFullMargin(mainBox, 10);

    setWindowChild(window, mainBox);
    showWindow(window);
}

int	main(int argc, char **argv) {

    GtkApplication *app;
    int status;

    app = createApplicationConnectActivate("gtk.example.template", 
                                G_APPLICATION_FLAGS_NONE, activate);
    // app = gtk_application_new("gtk.example.template", G_APPLICATION_FLAGS_NONE);
    // g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
    // status = g_application_run(G_APPLICATION(app), argc, argv);
    // g_object_unref(app);
    status = runApplication(app, argc, argv);
    objectUnref(app);

    return status;
}

